import request from '@/utils/request'

// 查询检查单列表
export function listChecklist(query) {
  return request({
    url: '/exam/checklist/list',
    method: 'get',
    params: query
  })
}

export function listAllChecklist() {
  return request({
    url: '/exam/checklist/listAll',
    method: 'get'
  })
}

// 查询检查单详细
export function getChecklist(checkListId) {
  return request({
    url: '/exam/checklist/' + checkListId,
    method: 'get'
  })
}

// 新增检查单
export function addChecklist(data) {
  return request({
    url: '/exam/checklist',
    method: 'post',
    data: data
  })
}

// 修改检查单
export function updateChecklist(data) {
  return request({
    url: '/exam/checklist',
    method: 'put',
    data: data
  })
}

// 删除检查单
export function delChecklist(checkListId) {
  return request({
    url: '/exam/checklist/' + checkListId,
    method: 'delete'
  })
}

// 批量新增检查单
export function addChecklists(fileName, checkListId, data) {
  return request({
    url: '/exam/checklistItem/batchInsert?fileName=' + fileName + '&checkListId=' + checkListId,
    method: 'post',
    data: data
  })
}

// 提交检查结果
export function submitCheckResult(checkListId, data) {
  return request({
    url: '/exam/checklistResultItem/batchAdd/' + checkListId,
    method: 'post',
    data: data
  })
}

// 获取提交的检查结果
export function getCheckResult(checkListId) {
  return request({
    url: '/exam/checklistResult/selectByCheckListId/' + checkListId,
    method: 'get'
  })
}

// 获取检查结果统计
export function getCheckResultStatistics(checkListId) {
  return request({
    url: '/exam/checklistItem/listState/' + checkListId,
    method: 'get'
  })
}

/**
 * 检查单下发
 * @param {*} data 
 * @returns 
 */
export function insertManyChecklistUser(data) {
  return request({
    url: '/exam/checklistResult/insertManyChecklistUser',
    method: 'post',
    data: data
  })
}

/**
 * 获取检查单填报记录列表
 * @param {*} checkListId 
 * @returns 
 */
export function selectExamChecklistUserByCheckListId(checkListId, params) {
  return request({
    url: '/exam/checklistResult/selectExamChecklistUserByCheckListId/' + checkListId,
    method: 'get',
    params: params
  })
}

/**
 * 查询待填报检查单
 * @param {*} checkListId 
 * @param {*} params 
 * @returns 
 */
export function selectExamChecklistUserByUserId(params) {
  return request({
    url: '/exam/checklistResult/selectExamChecklistUserByUserId',
    method: 'get',
    params: params
  })
}

/**
 * 获取所有检查单
 * @returns 
 */
export function listNoPage() {
  return request({
    url: '/exam/checklist/listNoPage',
    method: 'get',
  })
}

/**
 * 新增检查计划
 * @param {*} data 
 * @returns 
 */
export function addCheckListPlan(data) {
  return request({
    url: '/exam/plan',
    method: 'post',
    data: data
  })
}

/**
 * 检查计划列表
 * @returns 
 */
export function checkPlanList(params) {
  return request({
    url: '/exam/plan/list',
    method: 'get',
    params: params
  })
}

/**
 * 修改检查计划
 * @param {*} data 
 * @returns 
 */
export function updateCheckPlan(data) {
  return request({
    url: '/exam/plan',
    method: 'put',
    data: data
  })
}

/**
 * 删除检查计划
 * @param {*} id 
 * @returns 
 */
export function delCheckPlan(id) {
  return request({
    url: '/exam/plan/' + id,
    method: 'delete'
  })
}

/**
 * 立即执行检查任务
 * @param {*} data 
 * @returns 
 */
export function excuteCheckPlan(data) {
  return request({
    url: '/monitor/job/run',
    method: 'put',
    data: data
  })
}


